﻿using System.Net;
using Oxage.Common;

namespace Oxage.CNC.Models
{
	public class UdpModel : ModelBase
	{
		#region Constructor
		public UdpModel()
		{
			//Default values
			this.Host = "192.168.20.5";
			this.Port = 262; //262 aka CNC on phone keyboard
		}
		#endregion

		#region Public properties
		/// <summary>
		/// Gets or set the remote IP address.
		/// </summary>
		public string Host
		{
			get
			{
				return this.host;
			}
			set
			{
				if (this.host != value)
				{
					this.host = value;
					OnPropertyChanged("Host");
					OnPropertyChanged("EndPoint");
				}
			}
		}
		private string host;

		/// <summary>
		/// Gets or sets the remote port.
		/// </summary>
		public int Port
		{
			get
			{
				return this.port;
			}
			set
			{
				if (this.port != value)
				{
					this.port = value;
					OnPropertyChanged("Port");
					OnPropertyChanged("EndPoint");
				}
			}
		}
		private int port;

		/// <summary>
		/// Gets the IP end point build from host and port.
		/// </summary>
		public EndPoint EndPoint
		{
			get
			{
				return new IPEndPoint(IPAddress.Parse(this.Host), this.Port);
			}
		}
		#endregion
	}
}
